home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 June / CHIP_CD_2004-06.iso / software / miranda_hit / files / mirinstsetup.exe / Miranda Installer 0.0.1.2 / Procs.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-04-20  |  18.5 KB  |  550 lines

  1. /*
  2.     Miranda Installer - Installs nightlies and Miranda addons.
  3.     Copyright (C) 2002-2003 Goblineye Entertainment
  4.  
  5.     Authors: Saar (Tornado) and Kai (kai_b)
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20. */
  21.  
  22. #include "MirandaInstaller.h"
  23. #pragma hdrstop
  24.  
  25.  
  26.  
  27. INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
  28. {
  29.     switch(uMsg)
  30.     {
  31.         case WM_INITDIALOG:
  32.         {
  33.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_MIRANDADIR,EM_LIMITTEXT,MAX_PATH-1,0);
  34.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_ICONDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  35.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_SOUNDDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  36.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_LANGDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  37.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_TOOLDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  38.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_SRCDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  39.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_DOCSDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  40.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_SKINDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  41.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_SKINDIR,EM_LIMITTEXT,MAX_PATH-1,0);
  42.             SendDlgItemMessage(hwndDlg,IDC_OPTSDLG_PROFILENAME,EM_LIMITTEXT,MAX_PATH-1,0);
  43.  
  44.             if (lstrlen(g_WorkOptions.szMirandaDirectory) == 0) // nada. let's set it
  45.             {
  46.                 HKEY hKey;
  47.                 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Miranda",0,KEY_READ,&hKey) == ERROR_SUCCESS)
  48.                 {
  49.                     DWORD dwTemp = sizeof(g_WorkOptions.szMirandaDirectory);
  50.                     RegQueryValueEx(hKey,"Install_Dir",NULL,NULL,(LPBYTE)g_WorkOptions.szMirandaDirectory,&dwTemp);
  51.                     // normally a "to-be-careful" NULLing would go here, but strings in the registry
  52.                     // are always NULL terminated, so what's the point...
  53.                     RegCloseKey(hKey);
  54.  
  55.                     // if we have a backslash at the end, take it off
  56.                     if (*(g_WorkOptions.szMirandaDirectory + lstrlen(g_WorkOptions.szMirandaDirectory) - 1) == '\\')
  57.                     {
  58.                         *(g_WorkOptions.szMirandaDirectory + lstrlen(g_WorkOptions.szMirandaDirectory) - 1) = '\0';
  59.                     }
  60.                 }
  61.                 else // no registry stuff. use current directory
  62.                 {
  63.                     GetModuleFileName(NULL,g_WorkOptions.szMirandaDirectory,sizeof(g_WorkOptions.szMirandaDirectory));
  64.                     *strrchr(g_WorkOptions.szMirandaDirectory,'\\') = '\0';
  65.                 }
  66.  
  67.                 // apply to other directories
  68.                 for (byte index=0;index < 7;index++)
  69.                 {
  70.                     char *lpCopyTo; // exactly what it means
  71.                     char szTemp2[MAX_PATH + 1];
  72.                     lstrcpy(szTemp2,g_WorkOptions.szMirandaDirectory);
  73.                     lstrcat(szTemp2,"\\");
  74.  
  75.                     switch(index)
  76.                     {
  77.                         case 0:
  78.                         {
  79.                             lstrcat(szTemp2,"Icons");
  80.                             lpCopyTo = g_WorkOptions.szIconDirectory;
  81.                         } break;
  82.                         case 1:
  83.                         {
  84.                             lstrcat(szTemp2,"Sounds");
  85.                             lpCopyTo = g_WorkOptions.szSoundDirectory;
  86.                         } break;
  87.                         case 2:
  88.                         {
  89.                             lstrcat(szTemp2,"Language");
  90.                             lpCopyTo = g_WorkOptions.szLangDirectory;
  91.                         } break;
  92.                         case 3:
  93.                         {
  94.                             lstrcat(szTemp2,"Tools");
  95.                             lpCopyTo = g_WorkOptions.szToolDirectory;
  96.                         } break;
  97.                         case 4:
  98.                         {
  99.                             lstrcat(szTemp2,"Source");
  100.                             lpCopyTo = g_WorkOptions.szSrcDirectory;
  101.                         } break;
  102.                         case 5:
  103.                         {
  104.                             lstrcat(szTemp2,"Docs");
  105.                             lpCopyTo = g_WorkOptions.szDocDirectory;
  106.                         } break;
  107.                         case 6:
  108.                         {
  109.                             lstrcat(szTemp2,"Skins");
  110.                             lpCopyTo = g_WorkOptions.szSkinDirectory;
  111.                         } break;
  112.                     }
  113.  
  114.                     lstrcpy(lpCopyTo,szTemp2);
  115.                 }
  116.             }
  117.  
  118.             // now set all of it
  119.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_MIRANDADIR,g_WorkOptions.szMirandaDirectory);
  120.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_ICONDIR,g_WorkOptions.szIconDirectory);
  121.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_SOUNDDIR,g_WorkOptions.szSoundDirectory);
  122.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_LANGDIR,g_WorkOptions.szLangDirectory);
  123.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_TOOLDIR,g_WorkOptions.szToolDirectory);
  124.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_SRCDIR,g_WorkOptions.szSrcDirectory);
  125.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_DOCSDIR,g_WorkOptions.szDocDirectory);
  126.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_SKINDIR,g_WorkOptions.szSkinDirectory);
  127.             SetDlgItemText(hwndDlg,IDC_OPTSDLG_PROFILENAME,g_WorkOptions.szDefaultProfile);
  128.  
  129.             CheckDlgButton(hwndDlg,IDC_OPTSDLG_ASKAUTORUN,(g_WorkOptions.dwFlags & 1) ? (BST_CHECKED) : (BST_UNCHECKED));
  130.             CheckDlgButton(hwndDlg,IDC_OPTSDLG_ASKCLOSEMIR,(g_WorkOptions.dwFlags & 0x8) ? (BST_CHECKED) : (BST_UNCHECKED));
  131.  
  132.             byte bInstallType = (byte)((g_WorkOptions.dwFlags & 6) >> 1);
  133.             CheckRadioButton(hwndDlg,IDC_OPTSDLG_ALWAYSASK,IDC_OPTSDLG_ALWAYSALL,((bInstallType == 0) ? (IDC_OPTSDLG_ALWAYSASK) : ((bInstallType == 1) ? (IDC_OPTSDLG_ALWAYSALL) : (IDC_OPTSDLG_ALWAYSMAIN))));
  134.  
  135.             LP_TranslateDialog(hwndDlg);
  136.             return(true);
  137.         } break;
  138.         case WM_COMMAND:
  139.         {
  140.             if (HIWORD(wParam) == BN_CLICKED) // If we clicked
  141.             {
  142.                 switch (LOWORD(wParam)) 
  143.                 {
  144.                     case IDCANCEL:
  145.                     {
  146.                         EndDialog(hwndDlg,1);
  147.                         return(true);
  148.                     } break;
  149.                     case IDOK:
  150.                     {
  151.                         // save settings here
  152.                         char szTemp[MAX_PATH];
  153.                         char *lpCopyTo;
  154.  
  155.                         for (byte index=0;index < 8;index++)
  156.                         {
  157.                             GetDlgItemText(hwndDlg,IndexToDirID[index],szTemp,MAX_PATH);
  158.  
  159.                             switch(index)
  160.                             {
  161.                                 case 0: lpCopyTo = g_WorkOptions.szMirandaDirectory; break;
  162.                                 case 1: lpCopyTo = g_WorkOptions.szIconDirectory; break;
  163.                                 case 2: lpCopyTo = g_WorkOptions.szSoundDirectory; break;
  164.                                 case 3: lpCopyTo = g_WorkOptions.szLangDirectory; break;
  165.                                 case 4: lpCopyTo = g_WorkOptions.szToolDirectory; break;
  166.                                 case 5: lpCopyTo = g_WorkOptions.szSrcDirectory; break;
  167.                                 case 6: lpCopyTo = g_WorkOptions.szDocDirectory; break;
  168.                                 case 7: lpCopyTo = g_WorkOptions.szSkinDirectory; break;
  169.                             }
  170.  
  171.                             lstrcpy(lpCopyTo,szTemp);
  172.                         }
  173.  
  174.                         g_WorkOptions.dwFlags &= ~1;
  175.                         if (IsDlgButtonChecked(hwndDlg,IDC_OPTSDLG_ASKAUTORUN) == BST_CHECKED)
  176.                         {
  177.                             g_WorkOptions.dwFlags |= 1; // got it
  178.                         }
  179.  
  180.                         g_WorkOptions.dwFlags &= ~0x8;
  181.                         if (IsDlgButtonChecked(hwndDlg,IDC_OPTSDLG_ASKCLOSEMIR) == BST_CHECKED)
  182.                         {
  183.                             g_WorkOptions.dwFlags |= 0x8; // got it
  184.                         }
  185.  
  186.                         // installation type
  187.                         g_WorkOptions.dwFlags &= ~6; // clear
  188.                         if (IsDlgButtonChecked(hwndDlg,IDC_OPTSDLG_ALWAYSMAIN) == BST_CHECKED)
  189.                         {
  190.                             g_WorkOptions.dwFlags |= 4; // main
  191.                         }
  192.                         else if (IsDlgButtonChecked(hwndDlg,IDC_OPTSDLG_ALWAYSALL) == BST_CHECKED)
  193.                         {
  194.                             g_WorkOptions.dwFlags |= 2; // all
  195.                         }
  196.                         // no need to handle ask
  197.                         *szTemp = '\0';
  198.                         GetDlgItemText(hwndDlg,IDC_OPTSDLG_PROFILENAME,szTemp,MAX_PATH);
  199.                         if (*szTemp != '\0') // got smt there
  200.                         {
  201.                             CharLower(szTemp); // convert to lowercase
  202.                         }
  203.                         lstrcpy(g_WorkOptions.szDefaultProfile,szTemp);
  204.  
  205.                         EndDialog(hwndDlg,0);
  206.                         return(true);
  207.                     } break;
  208.                     case IDC_OPTSDLG_MIRBROWSE:
  209.                     case IDC_OPTSDLG_ICONBROWSE:
  210.                     case IDC_OPTSDLG_SOUNDBROWSE:
  211.                     case IDC_OPTSDLG_LANGBROWSE:
  212.                     case IDC_OPTSDLG_TOOLBROWSE:
  213.                     case IDC_OPTSDLG_SRCBROWSE:
  214.                     case IDC_OPTSDLG_DOCSBROWSE:
  215.                     case IDC_OPTSDLG_SKINBROWSE:
  216.                     {
  217.                         // more code from wassup
  218.                         // heh :)
  219.                         char szDirectory[MAX_PATH + 1];
  220.  
  221.                         BROWSEINFO browseInfo;
  222.                         ZeroMemory(&browseInfo,sizeof(BROWSEINFO)); // quicker than NULLing everything
  223.                         browseInfo.hwndOwner = hwndDlg;
  224.                         browseInfo.pszDisplayName = szDirectory;
  225.                         browseInfo.lpszTitle = Translate("Select directory:");
  226.                         browseInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  227.  
  228.                         LPITEMIDLIST idList;
  229.                         if (idList = SHBrowseForFolder(&browseInfo),idList != NULL) // old habit
  230.                         {
  231.                             LPMALLOC psMalloc; // [soon to be] pointer to shell's IMalloc object
  232.                             SHGetMalloc(&psMalloc);
  233.                             SHGetPathFromIDList(idList,szDirectory);
  234.                             psMalloc->Free(idList); // release the damn idList
  235.                             psMalloc->Release();
  236.  
  237.                             // ok now szDirectory is the directory where we're going to put our stuff
  238.                             // the lstrlen is so we won't cut up the string
  239.                             if ((szDirectory[lstrlen(szDirectory)-1] == '\\') && (lstrlen(szDirectory) > 1)) // backslash
  240.                             {
  241.                                 szDirectory[lstrlen(szDirectory)-1] = '\0';
  242.                             }
  243.  
  244.                             if (lstrlen(szDirectory) > 0)
  245.                             {
  246.                                 WORD wDestCtrl;
  247.                                 switch(LOWORD(wParam))
  248.                                 {
  249.                                     case IDC_OPTSDLG_MIRBROWSE: wDestCtrl = IDC_OPTSDLG_MIRANDADIR; break;
  250.                                     case IDC_OPTSDLG_ICONBROWSE: wDestCtrl = IDC_OPTSDLG_ICONDIR; break;
  251.                                     case IDC_OPTSDLG_SOUNDBROWSE: wDestCtrl = IDC_OPTSDLG_SOUNDDIR; break;
  252.                                     case IDC_OPTSDLG_LANGBROWSE: wDestCtrl = IDC_OPTSDLG_LANGDIR; break;
  253.                                     case IDC_OPTSDLG_TOOLBROWSE: wDestCtrl = IDC_OPTSDLG_TOOLDIR; break;
  254.                                     case IDC_OPTSDLG_SRCBROWSE: wDestCtrl = IDC_OPTSDLG_SRCDIR; break;
  255.                                     case IDC_OPTSDLG_DOCSBROWSE: wDestCtrl = IDC_OPTSDLG_DOCSDIR; break;
  256.                                     case IDC_OPTSDLG_SKINBROWSE: wDestCtrl = IDC_OPTSDLG_SKINDIR; break;
  257.                                 }
  258.                                 SetDlgItemText(hwndDlg,wDestCtrl,szDirectory);
  259.  
  260.                                 if (LOWORD(wParam) == IDC_OPTSDLG_MIRBROWSE)
  261.                                 {
  262.                                     // set it for the rest with the thingy
  263.                                     char szNewDir[MAX_PATH + 1];
  264.                                     lstrcat(szDirectory,"\\");
  265.  
  266.                                     for (byte index=0;index < 7;index++) // set for rest
  267.                                     {
  268.                                         lstrcpy(szNewDir,szDirectory);
  269.                                         switch(index)
  270.                                         {
  271.                                             case 0: lstrcat(szNewDir,"Icons"); break;
  272.                                             case 1: lstrcat(szNewDir,"Sounds"); break;
  273.                                             case 2: lstrcat(szNewDir,"Language"); break;
  274.                                             case 3: lstrcat(szNewDir,"Tools"); break;
  275.                                             case 4: lstrcat(szNewDir,"Source"); break;
  276.                                             case 5: lstrcat(szNewDir,"Docs"); break;
  277.                                             case 6: lstrcat(szNewDir,"Skins"); break;
  278.                                         }
  279.  
  280.                                         SetDlgItemText(hwndDlg,IDC_OPTSDLG_ICONDIR+index,szNewDir);
  281.                                     }
  282.                                 }
  283.                             }
  284.                         }
  285.                         return(true);
  286.                     } break;
  287.                 }
  288.             }
  289.         } break;
  290.         case WM_CLOSE:
  291.         {
  292.             EndDialog(hwndDlg,1);
  293.         } break;
  294.     }
  295.     return(false);
  296. }
  297.  
  298.  
  299.  
  300. INT_PTR CALLBACK LangPackDlgProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
  301. {
  302.     switch(uMsg)
  303.     {
  304.         case WM_INITDIALOG:
  305.         {
  306.             // ok now we find all langpacks in langdir
  307.             // then add current langpack
  308.             // if we find more than one current langpack (shouldn't be, but could be)
  309.             // then both are marked as "(current)"
  310.             HWND hComboBox = GetDlgItem(hwndDlg,IDC_LANGPACKDLG_LPCOMBO);
  311.             char szSearchPath[MAX_PATH + 1];
  312.             WIN32_FIND_DATA findData;
  313.             wsprintf(szSearchPath,"%s\\langpack_*.txt",g_WorkOptions.szLangDirectory);
  314.  
  315.             // before we start, we add a "(No langpack)" string
  316.             SendMessage(hComboBox,CB_ADDSTRING,0,(LPARAM)Translate("(No Language Pack)"));
  317.             SendMessage(hComboBox,CB_SETITEMDATA,0,2); // no langpack
  318.             SendMessage(hComboBox,CB_SETCURSEL,0,0); // cursel
  319.  
  320.             HANDLE hFindFile;
  321.             if (hFindFile = FindFirstFile(szSearchPath,&findData), hFindFile != INVALID_HANDLE_VALUE)
  322.             {
  323.                 do
  324.                 {
  325.                     *strrchr(findData.cFileName,'.') = '\0'; // cut extension
  326.                     CharLower(findData.cFileName); // convert to lowercase
  327.                     int iItem = SendMessage(hComboBox,CB_ADDSTRING,0,(LPARAM)findData.cFileName);
  328.  
  329.                     SendMessage(hComboBox,CB_SETITEMDATA,iItem,0); // not active
  330.                 } while (FindNextFile(hFindFile,&findData));
  331.             }
  332.  
  333.             // now find installed langpack[s]
  334.             wsprintf(szSearchPath,"%s\\langpack_*.txt",g_WorkOptions.szMirandaDirectory);
  335.             if (hFindFile = FindFirstFile(szSearchPath,&findData), hFindFile != INVALID_HANDLE_VALUE)
  336.             {
  337.                 do
  338.                 {
  339.                     char szTemp[MAX_PATH+32]; // to be safe. buffer overrun sux.
  340.                     *strrchr(findData.cFileName,'.') = '\0'; // cut extension
  341.                     CharLower(findData.cFileName); // convert to lowercase
  342.  
  343.                     // let's try to find this lang pack in the current list
  344.                     // if it's there, we will delete that file from the list
  345.                     // no need to delete it from the dir, it'll be overwritten
  346.                     int iSearchItem = SendMessage(hComboBox,CB_FINDSTRINGEXACT,-1,(LPARAM)findData.cFileName);
  347.                     if (iSearchItem != CB_ERR)
  348.                     {
  349.                         SendMessage(hComboBox,CB_DELETESTRING,iSearchItem,0); // gone
  350.                     }
  351.  
  352.                     wsprintf(szTemp,Translate("%s (Current)"),findData.cFileName);
  353.                     findData.cFileName[lstrlen(findData.cFileName)] = '.'; // bring it back (needed soon)
  354.  
  355.                     int iItem = SendMessage(hComboBox,CB_INSERTSTRING,1,(LPARAM)szTemp);
  356.  
  357.                     SendMessage(hComboBox,CB_SETITEMDATA,iItem,1); // active
  358.                     SendMessage(hComboBox,CB_SETCURSEL,iItem,0); // cursel
  359.  
  360.                     // now move file from main dir to lang dir
  361.                     // szSearchPath is dest
  362.                     wsprintf(szSearchPath,"%s\\%s",g_WorkOptions.szLangDirectory,findData.cFileName);
  363.                     wsprintf(szTemp,"%s\\%s",g_WorkOptions.szMirandaDirectory,findData.cFileName);
  364.                     MoveFile(szTemp,szSearchPath); // MoveFileEx isn't supported on 9x
  365.                 } while (FindNextFile(hFindFile,&findData));
  366.             }
  367.  
  368.             LP_TranslateDialog(hwndDlg);
  369.             return(true);
  370.         } break;
  371.         case WM_COMMAND:
  372.         {
  373.             if (HIWORD(wParam) == BN_CLICKED) // If we clicked
  374.             {
  375.                 switch (LOWORD(wParam)) 
  376.                 {
  377.                     case IDOK:
  378.                     {
  379.                         // copy back selection
  380.                         HWND hComboBox = GetDlgItem(hwndDlg,IDC_LANGPACKDLG_LPCOMBO);
  381.                         int iCurSel = SendMessage(hComboBox,CB_GETCURSEL,0,0);
  382.                         if (iCurSel == CB_ERR)
  383.                         {
  384.                             iCurSel = 0; // make it 0
  385.                         }
  386.  
  387.                         int iType = SendMessage(hComboBox,CB_GETITEMDATA,iCurSel,0);
  388.                         if (iType != 2) // we don't do anything, no langpack is to be used
  389.                         {
  390.                             int iLen = SendMessage(hComboBox,WM_GETTEXTLENGTH,0,0);
  391.                             if (iLen > 0) // caution
  392.                             {
  393.                                 char szSrc[MAX_PATH + 1], szDest[MAX_PATH + 1];
  394.                                 char *szTemp = new char[iLen + 1]; // not a big fan of allocation for practically nothing, but this is better
  395.                                 GetDlgItemText(hwndDlg,IDC_LANGPACKDLG_LPCOMBO,szTemp,iLen+1);
  396.  
  397.                                 if (iType == 1) // active
  398.                                 {
  399.                                     *(strrchr(szTemp,'(')-1) = '\0'; // take off the ending
  400.                                 }
  401.  
  402.                                 wsprintf(szSrc,"%s\\%s.txt",g_WorkOptions.szLangDirectory,szTemp);
  403.                                 wsprintf(szDest,"%s\\%s.txt",g_WorkOptions.szMirandaDirectory,szTemp);
  404.  
  405.                                 MoveFile(szSrc,szDest);
  406.                                 
  407.                                 delete [] szTemp;
  408.                             }
  409.                         }
  410.                         EndDialog(hwndDlg,1);
  411.                         return(true);
  412.                     } break;
  413.                     case IDCANCEL:
  414.                     {
  415.                         // we copy back a current one
  416.                         HWND hComboBox = GetDlgItem(hwndDlg,IDC_LANGPACKDLG_LPCOMBO);
  417.                         for (int index=0, iCount = SendMessage(hComboBox,CB_GETCOUNT,0,0);index < iCount;index++)
  418.                         {
  419.                             if (SendMessage(hComboBox,CB_GETITEMDATA,index,0) == 1) // current
  420.                             {
  421.                                 int iLen = SendMessage(hComboBox,WM_GETTEXTLENGTH,0,0);
  422.                                 if (iLen > 0) // caution
  423.                                 {
  424.                                     char szSrc[MAX_PATH + 1], szDest[MAX_PATH + 1];
  425.                                     char *szTemp = new char[iLen + 1];
  426.                                     GetDlgItemText(hwndDlg,IDC_LANGPACKDLG_LPCOMBO,szTemp,iLen+1);
  427.  
  428.                                     *(strrchr(szTemp,'(')-1) = '\0'; // take off the ending
  429.  
  430.                                     wsprintf(szSrc,"%s\\%s.txt",g_WorkOptions.szLangDirectory,szTemp);
  431.                                     wsprintf(szDest,"%s\\%s.txt",g_WorkOptions.szMirandaDirectory,szTemp);
  432.  
  433.                                     MoveFile(szSrc,szDest);
  434.                                     
  435.                                     delete [] szTemp;
  436.                                     break;
  437.                                 }
  438.                             }
  439.                         }
  440.                         EndDialog(hwndDlg,0);
  441.                     } break;
  442.                 }
  443.             }
  444.         } break;
  445.         case WM_CLOSE:
  446.         {
  447.             return(true);
  448.         } break;
  449.     }
  450.     return(false);
  451. }
  452.  
  453.  
  454.  
  455. INT_PTR CALLBACK AboutDlgProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
  456. {
  457.     static HFONT s_hFont = NULL;
  458.     static HCURSOR s_hCursor = NULL;
  459.  
  460.     switch(uMsg)
  461.     {
  462.         case WM_INITDIALOG:
  463.         {
  464.             LP_TranslateDialog(hwndDlg);
  465.  
  466.             HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg,IDC_ABOUTDLG_HYPERLINK,WM_GETFONT,0,0); // try getting the font used by the control
  467.  
  468.             if (hFont == NULL) // if none...
  469.                 hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); // get the default font used by the GUI
  470.  
  471.             LOGFONT logFont; // font information
  472.             GetObject(hFont,sizeof(logFont),&logFont); // get font information
  473.             logFont.lfUnderline = true; // underline it
  474.             s_hFont = CreateFontIndirect(&logFont); // recreate the font, underlined
  475.  
  476.             char szBuffer[32]; // big enough
  477.             GetDlgItemText(hwndDlg,IDC_ABOUTDLG_HYPERLINK,szBuffer,32);
  478.  
  479.             if (s_hFont != NULL)
  480.             {
  481.                 SendDlgItemMessage(hwndDlg,IDC_ABOUTDLG_HYPERLINK,WM_SETFONT,(WPARAM)s_hFont,true);
  482.             }
  483.  
  484.             OSVERSIONINFO osVers;
  485.             osVers.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  486.             GetVersionEx(&osVers);
  487.             if ((osVers.dwMajorVersion == 5) || ((osVers.dwMajorVersion == 4) && ((osVers.dwMinorVersion == 10) || (osVers.dwMinorVersion == 90))))
  488.             {
  489.                 s_hCursor = LoadCursor(NULL,IDC_HAND);
  490.             }
  491.             else
  492.             {
  493.                 s_hCursor = LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_MYHAND));
  494.             }
  495.         } break;
  496.         case WM_COMMAND:
  497.         {
  498.             if (HIWORD(wParam) == BN_CLICKED) // If we clicked
  499.             {
  500.                 switch (LOWORD(wParam)) 
  501.                 {
  502.                     case IDCANCEL:
  503.                     {
  504.                         EndDialog(hwndDlg,1);
  505.                         return(true);
  506.                     } break;
  507.                     case IDC_ABOUTDLG_HYPERLINK: // the hyperlink text was clicked
  508.                     {
  509.                         char szBuffer[32]; // big enough
  510.                         GetDlgItemText(hwndDlg,IDC_ABOUTDLG_HYPERLINK,szBuffer,32);
  511.                         ShellExecute(NULL,"open",szBuffer,NULL,NULL,SW_SHOWNORMAL);
  512.                         EndDialog(hwndDlg,1); // close this dialog
  513.                         return(true);
  514.                     } break;
  515.                 }
  516.             }
  517.         } break;
  518.         case WM_SETCURSOR: // the mouse is moving
  519.         {
  520.             if ((HWND)wParam == GetDlgItem(hwndDlg,IDC_ABOUTDLG_HYPERLINK))
  521.             {
  522.                 SetCursor(s_hCursor);
  523.                 SetWindowLongPtr(hwndDlg,DWL_MSGRESULT,true);
  524.                 return(true);
  525.             }
  526.         } break;
  527.         case WM_CTLCOLORSTATIC:
  528.         {
  529.             // draw the text in a different color
  530.             HWND hwndDraw = (HWND)lParam;
  531.             if (hwndDraw == GetDlgItem(hwndDlg,IDC_ABOUTDLG_HYPERLINK))
  532.             {
  533.                 HDC hDC = (HDC)wParam;
  534.                 SetTextColor(hDC,RGB(0,0,255));
  535.                 SetBkMode(hDC,TRANSPARENT);
  536.                 return((BOOL)GetStockObject(NULL_BRUSH));
  537.             }
  538.         } break;
  539.         case WM_DESTROY:
  540.         {
  541.             if (s_hFont != NULL)
  542.             {
  543.                 SendDlgItemMessage(hwndDlg,IDC_ABOUTDLG_HYPERLINK,WM_SETFONT,NULL,true);
  544.                 DeleteObject(s_hFont);
  545.             }
  546.         } break;
  547.         default:break;
  548.     }
  549.     return(false);
  550. }